import {getMessage} from "@/api/message";
import {getImages, getMusics} from "@/api/room";

function getList(){
    let list = []
    getMessage(this.rid)
        .then(async response => {
            let rList = response.data
            for (let i = 0; i < rList.length; i++) {
                let item = rList[i];
                let message = {
                    date: item.createTime,
                    mine: false,
                    name: item.username,
                    img: item.avatar,
                    text: {text: item.message}
                };
                if (item.uid != window.sessionStorage.getItem("uid")) {
                    message.mine = false
                } else {
                    message.mine = true
                }
                console.log(item)
                console.log(message.text)
                list.push(message);
            }
        })
}
function getImages(){
    let imgList = []
    getImages(this.rid)
        .then(response => {
            imgList = response.data;
            console.log(imgList)
        })
}
function initAudio() {
    // 创建一个音乐播放器实例，并挂载到DOM上，同时进行相关配置
    let list = []
    getMusics(this.rid)
        .then(response => {
            list.add(response.data)
            console.log(list)
        })
}

getList()
getImages()
initAudio()